package bb.lanxing.network;

import static bb.lanxing.activity.routebook.RouteBookInfoActivity.REQUEST_TYPE_ROUTE_BOOK_COMMENT;
import static bb.lanxing.common.config.Constants.REQUEST_PREFIX;
import static bb.lanxing.manager.SharedManager.KEY_TOKEN;

import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import javax.net.ssl.HttpsURLConnection;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.baidu.mapapi.model.LatLng;
import com.baidu.platform.comapi.map.MapBundleKey;
import com.bes.sdk.message.MsgStrAnalyzer;
import com.github.mikephil.charting.utils.Utils;
import com.umeng.socialize.net.dplus.CommonNetImpl;
import com.umeng.socialize.net.utils.SocializeProtocolConstants;

import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;

import androidx.annotation.NonNull;

import bb.lanxing.App;
import bb.lanxing.activity.deeplink.DeepLinkPathConstants;
import bb.lanxing.activity.sport.SportActivity;
import bb.lanxing.calc.data.DisplayPoint;
import bb.lanxing.common.config.Constants;
import bb.lanxing.lib.kt.model.geo.IGeoPoint;
import bb.lanxing.manager.SharedManager;
import bb.lanxing.model.WorkoutContentProvider;
import bb.lanxing.model.database.Bbs;
import bb.lanxing.model.database.Device;
import bb.lanxing.model.database.Event;
import bb.lanxing.model.database.RouteBook;
import bb.lanxing.model.database.RouteBookPoint;
import bb.lanxing.model.database.UserCard;
import bb.lanxing.model.database.Waypoint;
import bb.lanxing.model.database.Workout;
import bb.lanxing.model.json.WorkoutExtraInfo;
import bb.lanxing.model.json.club.PostClubNews;
import bb.lanxing.model.map.GeoPoint;
import bb.lanxing.mvp.presetner.ClubPresenter;
import bb.lanxing.net.ApiClientConfigs;
import bb.lanxing.net.client.HttpProxy;
import bb.lanxing.test.PolylineUtil;
import bb.lanxing.util.AppFileUtils;
import bb.lanxing.util.BusProvider;
import bb.lanxing.util.CommonUtil;
import bb.lanxing.util.Log;
import bb.lanxing.util.WorkoutTitleUtil;
import bb.lanxing.utils.DateUtil;
import okhttp3.Cache;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.ConnectionSpec;
import okhttp3.FormBody;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.internal.tls.OkHostnameVerifier;

public class MyHttpClient {
    public static final String CLIENT_COOKIE_NAME = "sessionid";
    public static final MediaType JSON = MediaType.parse(bb.lanxing.net.client.HttpProxy.MEDIA_JSON);
    private static final long TIME_OUT = 120L;
    final private static String TAG = "MyHttpClient";
    private static final MediaType MEDIA_TYPE_GZIP = MediaType.parse(HttpProxy.MEDIA_TYPE_GZIP);
    private static final MediaType MEDIA_TYPE_OCTET_STREAM = MediaType.parse("application/octet-stream");
    public static String H5_DOMAIN_BASE = "app.bluebank.com.cn";
    public static OkHttpClient client;
    public static String DOMAIN = null;
    public static String DOMAIN_BASE = null;
    public static String DOMAIN_BASE_PURE = null;
    public static String DOMAIN_DEFAULT = "woc.bluebank.com.cn";
    public static String DOMAIN_PURE_DEFAULT = "bluebank.com.cn";
    public static String PROJECT_NAME = "bc270";

    static String userAgent = "Android";

    private MyHttpClient() {
    }

    public static void cleanCache() {
    }

    public static void init(String str) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        builder.connectTimeout(TIME_OUT, TimeUnit.SECONDS)
                .connectionSpecs(Arrays.asList(ConnectionSpec.CLEARTEXT, ConnectionSpec.MODERN_TLS))
                .readTimeout(TIME_OUT, TimeUnit.SECONDS).writeTimeout(TIME_OUT, TimeUnit.SECONDS)
                .cookieJar(new CookieJarImpl());
        String buildExternalDirectoryPath = AppFileUtils.buildExternalDirectoryPath(Constants.HTTP_CACHE);
        if (!TextUtils.isEmpty(buildExternalDirectoryPath)) {
            builder.cache(new Cache(new File(buildExternalDirectoryPath), CommonNetImpl.MAX_SIZE_IN_KB));
        }
        builder.interceptors().add(new BiciCacheControl());
        builder.interceptors().add(new HttpsInterceptor());
         //builder.interceptors().add(ProgressIntercept.INSTANCE);
        client = builder.build();
        if (!TextUtils.isEmpty(str)) {
            userAgent = str;
        }
        BusProvider.getInstance().register(new MyHttpClient());
        initDomain();
        initHttps();
    }

    public static void clearCookie() {
        CookieJarImpl.clear();
    }

    public static void initDomain() {
        int httpDomain = App.getContext().getHttpDomain();
        if (httpDomain == 1) {
            DOMAIN_BASE = DOMAIN_DEFAULT;
            DOMAIN_BASE_PURE = DOMAIN_PURE_DEFAULT;
        } else if (httpDomain == 2) {
            int i = SharedManager.getInstance().getInt("httpDomain_port", 80);
            if (i == 80) {
                DOMAIN_BASE = "backup.bluebank.com.cn";
            } else {
                DOMAIN_BASE = "backup" + i + ".bluebank.com.cn/";
            }
            DOMAIN_BASE_PURE = "bluebank.com.cn";
        } else if (httpDomain == 3) {
            DOMAIN_BASE = "woc2.mexica.cn";
            DOMAIN_BASE_PURE = "mexica.cn";
            DOMAIN_DEFAULT = "woc2.mexica.cn";
            DOMAIN_PURE_DEFAULT = "mexica.cn";
        } else if (httpDomain == 4) {
            String string = SharedManager.getInstance().getString("baseUrl", "woc.bluebank.com.cn");
            DOMAIN_BASE = string;
            DOMAIN_BASE_PURE = getPureDomain(string);
        } else if (httpDomain == 5) {
            DOMAIN_BASE = "woc.bluebank.com.cn";
            DOMAIN_BASE_PURE = "bluebank.com.cn";

        }

        DOMAIN = ApiClientConfigs.PROTOCOL_HTTP + DOMAIN_BASE + "/";
        ApiRequestBuilder.init("https://woc." + DOMAIN_BASE_PURE + "/");

        // if (httpDomain != 5) {
        // DOMAIN = ApiClientConfigs.PROTOCOL_HTTP + DOMAIN_BASE + "/api/";
        // ApiRequestBuilder.init("https://api." + DOMAIN_BASE_PURE + "/");
        // }

    }

    static Request.Builder getBiCiRequestBuilderWithSportUpload(String prefix, String path) {
        if (client == null) {
            init(null);
        }
        String token = SharedManager.getInstance().getString(KEY_TOKEN, "");
        Request.Builder builder = new Request.Builder();
        return builder
                .url(Uri.parse(DOMAIN).buildUpon().appendEncodedPath(prefix).appendEncodedPath(path).build().toString())
                .header("User-Agent", userAgent).addHeader("Authorization", token);
    }

    static Request.Builder getBiCiRequestBuilder(String str) {
        return getBiCiRequestBuilder("prod-api/", str);
    }

    public static String buildUrlByParams(String str, Map<String, Object> map) {
        Uri.Builder buildUpon = Uri.parse(str).buildUpon();
        if (map != null) {
            for (String str2 : map.keySet()) {
                try {
                    buildUpon.appendQueryParameter(str2, String.valueOf(map.get(str2)));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return buildUpon.toString();
    }

    private static String getPureDomain(String str) {
        String[] split = str.split("\\.");
        if (split.length > 2) {
            return split[split.length - 2] + "." + split[split.length - 1];
        }
        return str;
    }

    // line 185
    private static void initHttps() {
        HttpsURLConnection.setDefaultHostnameVerifier(OkHostnameVerifier.INSTANCE);
    }

    // line 189
    static Request.Builder getBiCiRequestBuilder(String prefix, String path) {
        if (client == null) {
            init(null);
        }
        String token = SharedManager.getInstance().getString(KEY_TOKEN, "");
        return new Request.Builder()
                .url(Uri.parse(DOMAIN).buildUpon().appendEncodedPath(prefix).appendEncodedPath(path).build().toString())
                .header("User-Agent", userAgent).addHeader("Accept", "application/json")
                .addHeader("Content-type", "application/json").addHeader("Authorization", token);

    }

    static Request.Builder getMyRequestBuilder(String prefix, String path, boolean useToken) {
        if (client == null) {
            init(null);
        }
        if (useToken) {
            String token = SharedManager.getInstance().getString(KEY_TOKEN, "");
            return new Request.Builder()
                    .url(Uri.parse(DOMAIN).buildUpon().appendEncodedPath(prefix).appendEncodedPath(path).build()
                            .toString())
                    .header("User-Agent", userAgent).addHeader("Accept", "application/json")
                    .addHeader("Content-type", "application/json").addHeader("Authorization", token);
        } else {
            return new Request.Builder()
                    .url(Uri.parse(DOMAIN).buildUpon().appendEncodedPath(prefix).appendEncodedPath(path).build()
                            .toString())
                    .header("User-Agent", userAgent).addHeader("Accept", "application/json")
                    .addHeader("Content-type", "application/json");
        }
    }

    public static String buildUrlByPath(String str, String param) {
        Uri.Builder buildUpon = Uri.parse(str).buildUpon();

        try {
            buildUpon.appendPath(param);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return buildUpon.toString();
    }

    // line 250
    public static String buildSimpleJson(Map<String, Object> map) {
        JSONObject jSONObject = new JSONObject();
        for (String str : map.keySet()) {
            try {
                jSONObject.put(str, map.get(str));
            } catch (Exception e) {
                e.printStackTrace();
                if (App.getContext().isDebugMode()) {
                    App.getContext().showMessage("httpclient build json error ！！！");
                }
            }
        }
        return jSONObject.toString();
    }

    public static void requestUserInfo(Callback callback, long userId) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("userId", userId);
        hashMap.put("time", System.currentTimeMillis());
        Request build = getBiCiRequestBuilder("prod-api/", "account/get_user_info").get().build();
        Log.d(TAG, "requestUserInfo: " + "请求用户个人信息 request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void requestUserHistoryYears(Callback callback, long userId) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("userId", userId);
        String path = buildUrlByParams("bluerider/workout/workout_summary", hashMap);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, path).get().build();
        client.newCall(build).enqueue(callback);
    }

    public static Call requestUserHistoryYears(long userId) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("userId", userId);
        String path = buildUrlByParams("bluerider/workout/workout_summary", hashMap);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, path).get().build();
        return client.newCall(build);
    }

    public static void getAllWorkouts(Callback callback, int year, long userId) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("year", year);
        hashMap.put("userId", userId);
        hashMap.put("timestamp", System.currentTimeMillis());// UMCrash.SP_KEY_TIMESTAMP

        String yearStr = String.valueOf(year);
        String path = buildUrlByPath("bluerider/workout/month_list", yearStr);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, path).get().build();
        client.newCall(build).enqueue(callback);
    }

    public static Call downloadWorkouts(int year, long userId) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("year", year);
        hashMap.put("userId", userId);
        hashMap.put("timestamp", System.currentTimeMillis());// UMCrash.SP_KEY_TIMESTAMP

        String yearStr = String.valueOf(year);
        String path = buildUrlByPath("bluerider/workout/new_workout_list", yearStr);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, path).get().build();
        return client.newCall(build);
    }

    public static Call downloadAllPoints(String uuid, long serverId) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("timestamp", System.currentTimeMillis());
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX,
                buildUrlByParams("bluerider/workout/pgworkout/" + serverId + "/trackpoints/", hashMap)).build();
        Log.d(TAG, "downloadAllPoints: " + build);
        return client.newCall(build);
    }

    public static void downloadAllPoints(Callback callback, long serverId) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("timestamp", System.currentTimeMillis());
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX,
                buildUrlByParams("bluerider/workout/pgworkout/" + serverId + "/trackpoints/", hashMap)).build();
        Log.d(TAG, "downloadAllPoints: " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void getWorkoutDetail(Callback callback, long workoutServerId) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverId", workoutServerId);
        hashMap.put("timestamp", System.currentTimeMillis());
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "bluerider/workout/segment_workout/")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        client.newCall(build).enqueue(callback);
    }

    public static void updateUserProfile(Callback callback, Map<String, Object> map) {
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "account/update_user_info")
                .post(RequestBody.create(JSON, buildSimpleJson(map))).build();
        Log.d(TAG, "updateUserProfile: " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void requestCollectionLushuList(Callback callback) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("time", System.currentTimeMillis());
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("/bluerider/lushu/lushu_favorite", hashMap))
                        .get().build();
        Log.d(TAG, "requestCollectionLushuList:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call requestLushuCollectionList(int type, int pageNum, int limit, double lat, double lng,
                                                  long provinceId) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("time", System.currentTimeMillis());
        hashMap.put("pageNum", pageNum);
        hashMap.put("pageSize", limit);
        hashMap.put("type", type);
        hashMap.put("latitude", lat);
        hashMap.put("longitude", lng);
        hashMap.put("orderByColumn", "serverId");
        hashMap.put("isAsc", "desc");
        hashMap.put("provinceId", provinceId);
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("/bluerider/lushu/recommend_list", hashMap))
                        .get().build();
        Log.d(TAG, "requestLushuCollectionList:" + build);
        return client.newCall(build);
    }

    public static Call requestLushuCollectionDetail(long lushuId) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("time", System.currentTimeMillis());
        hashMap.put("serverId", lushuId);
        return client.newCall(
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("/bluerider/lushu/collection_info", hashMap))
                        .get().build());
    }

    public static Call postLushuCollectionLike(long lushuId) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverId", lushuId);// lushu_collection_id
        return client.newCall(getBiCiRequestBuilder(REQUEST_PREFIX, "/bluerider/lushu/collection_like")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build());
    }

    public static Call checkLushuForUpdate(List<Long> list) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverIds", new JSONArray(list));
        return client.newCall(getBiCiRequestBuilder(REQUEST_PREFIX, "/bluerider/lushu/lushu_check")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build());
    }

    public static void requestNearbyLushuList(Callback callback, int pageNum, int pageSize) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("type", 3);
        LatLng curLatLngWithMP = SharedManager.getInstance().getCurLatLngWithMP();
        hashMap.put("latitude", curLatLngWithMP.latitude);
        hashMap.put("longitude", curLatLngWithMP.longitude);
        if (pageNum >= 0 && pageSize > 0) {
            hashMap.put("pageNum", pageNum);
            hashMap.put("pageSize", pageSize);// WorkoutContentProvider.QUERY_PARAM_LIMIT
        }
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("/bluerider/lushu/lushu_search", hashMap)).get()
                        .build();
        Log.d(TAG, "requestNearbyLushuList:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static void requestHotLushuList(Callback callback, int pageNum, int pageSize) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("type", 3);
        LatLng curLatLngWithMP = SharedManager.getInstance().getCurLatLngWithMP();
        hashMap.put("latitude", curLatLngWithMP.latitude);
        hashMap.put("longitude", curLatLngWithMP.longitude);
        if (pageNum >= 0 && pageSize > 0) {
            hashMap.put("pageNum", pageNum);
            hashMap.put("pageSize", pageSize);// WorkoutContentProvider.QUERY_PARAM_LIMIT
        }
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("/bluerider/lushu/lushu_hot", hashMap)).build();
        Log.d(TAG, "requestHotLushuList:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static void requestMyLushuList(Callback callback, int pageNum) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("time", System.currentTimeMillis());
        hashMap.put("pageSize", 20);// WorkoutContentProvider.QUERY_PARAM_LIMIT
        // hashMap.put("offset", i * 20);
        hashMap.put("pageNum", pageNum);
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("/bluerider/lushu/lushu_mine", hashMap)).build();
        Log.d(TAG, "requestMyLushuList:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static void deleteLushuById(long lushuId, Callback callback) {
        // HashMap<String, Object> hashMap = new HashMap<>();
        // hashMap.put("serverId", lushuId);
        // Request.Builder builder = new Request.Builder();

        String url = "/bluerider/lushu/delete/" + lushuId;
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, url).delete().build();
        Log.d(TAG, "deleteWorkout:" + build);
        client.newCall(build).enqueue(callback);

        // client.newCall(builder.url(DOMAIN +
        // "v4/toggle_delete_lushu").post(RequestBody.create(MediaType.parse("text/html"),
        // buildSimpleJson(hashMap))).build()).enqueue(callback);
    }

    public static Call requestLushuInfo(long lushuId, int type) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverId", lushuId);
        hashMap.put("type", type);
        hashMap.put("time", System.currentTimeMillis());
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("/bluerider/lushu/lushu_info", hashMap))
                .get().build();
        Log.d(TAG, "requestLushuInfo:" + build);
        return client.newCall(build);
    }

    public static void requestLushuInfo(long lushuId, int type, Callback callback) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverId", lushuId);
        hashMap.put("type", type);
        hashMap.put("time", System.currentTimeMillis());
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("/bluerider/lushu/lushu_info", hashMap))
                .get().build();
        Log.d(TAG, "requestLushuInfo:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call requestLushuComment(long lushuId, int offset, int limit) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverId", lushuId);
        hashMap.put("type", REQUEST_TYPE_ROUTE_BOOK_COMMENT);
        hashMap.put("time", System.currentTimeMillis());
        hashMap.put("pageNum", offset);
        hashMap.put("pageSize", limit);// WorkoutContentProvider.QUERY_PARAM_LIMIT
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("/bluerider/lushu/lushu_info", hashMap)).build();
        Log.d(TAG, "requestLushuComment:" + build);
        return client.newCall(build);
    }

    public static Call deleteCommentForLushu(long action, long comment_id) {
        Request build = getMyRequestBuilder(REQUEST_PREFIX, buildUrlByParams(
                "/bluerider/" + Constants.LUSHU_IMPORT + "lushu_comment?comment_id=" + comment_id, null), true).delete()
                .build();
        return client.newCall(build);
    }

    public static Call commentLushu(long serverId, String content, String photoUrl, long reply_ids) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverId", serverId);// SportActivity.EXTRA_LUSHU_ID
        hashMap.put("content", content);
        hashMap.put("type", !TextUtils.isEmpty(photoUrl) ? 1 : 0);
        if (!TextUtils.isEmpty(photoUrl)) {
            hashMap.put("image", photoUrl);// SocializeProtocolConstants.IMAGE
        }
        if (reply_ids > 0) {
            hashMap.put("reply_ids", reply_ids);// reply_ids is from informedUserId
        }
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "/bluerider/lushu/lushu_comment")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "commentLushu:" + build);
        return client.newCall(build);
    }

    public static void editLushu(RouteBook routeBook, Callback callback) {
        String title = routeBook.getTitle();
        if (TextUtils.isEmpty(title)) {
            title = "";
        }
        String description = routeBook.getDescription();
        if (TextUtils.isEmpty(description)) {
            description = "";
        }

        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverId", routeBook.getServerId());// SportActivity.EXTRA_LUSHU_ID
        hashMap.put("description", description);
        hashMap.put("title", title);
        hashMap.put("sport", routeBook.getSport());

        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "/bluerider/lushu/edit")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "edit Lushu:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static void uploadLushu2(RouteBook routeBook, String filePath, File file, Callback callback) {
        long lushuId = routeBook.getId();
        List<Waypoint> waypointList = Waypoint.getByLushuId(lushuId);
        List<RouteBookPoint> lushuPointList = RouteBookPoint.getByLushuId(lushuId);
        String md5 = CommonUtil.getMD5(file);
        JSONArray jSONArrayWaypoint = new JSONArray();
        if (null != waypointList) {
            for (Waypoint waypoint : waypointList) {
                JSONObject jSONObject = new JSONObject();
                try {
                    jSONObject.put("latitude", waypoint.getLatitude());
                    jSONObject.put("longitude", waypoint.getLongitude());
                    jSONObject.put("title", waypoint.getTitle());
                    jSONObject.put("content", waypoint.getContent());
                    jSONObject.put("image", waypoint.getImage());
                    jSONObject.put("type", waypoint.getType());
                    jSONObject.put("wayPointIndex", waypoint.getId());
                    jSONArrayWaypoint.put(jSONObject);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
        JSONArray jSONArrayLushupoint = new JSONArray();
        if (null != lushuPointList) {
            for (RouteBookPoint lushuPoint : lushuPointList) {
                JSONObject jSONObject = new JSONObject();
                try {
                    jSONObject.put("latitude", lushuPoint.getLatitude());
                    jSONObject.put("longitude", lushuPoint.getLongitude());
                    jSONObject.put("altitude", lushuPoint.getAltitude());
                    jSONObject.put("distance", lushuPoint.getDistance());
                    jSONObject.put("lushuPointIndex", lushuPoint.getId());
                    jSONArrayLushupoint.put(jSONObject);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }

        MultipartBody.Builder addFormDataPart = new MultipartBody.Builder().setType(MultipartBody.FORM);
        JSONObject blueriderLushu = new JSONObject();
        try {
            blueriderLushu.put("lushuPoints", jSONArrayLushupoint);
            blueriderLushu.put("wayPoints", jSONArrayWaypoint);
            blueriderLushu.put("title", routeBook.getTitle() == null ? "" : routeBook.getTitle());
            blueriderLushu.put("uuid", routeBook.getUuid());
            blueriderLushu.put("distance", String.valueOf(routeBook.getDistance()));
            blueriderLushu.put("description", routeBook.getDescription() == null ? "" : routeBook.getDescription());
            blueriderLushu.put("sport", String.valueOf(routeBook.getSport()));
            blueriderLushu.put("sourceType", String.valueOf(routeBook.getSourceType()));

        } catch (Exception e) {
            e.printStackTrace();
        }

        addFormDataPart.addFormDataPart("lushu", blueriderLushu.toString());
        addFormDataPart.addFormDataPart("md5File", md5);
        if (!TextUtils.isEmpty(filePath) && null != file) {
            addFormDataPart.addFormDataPart("upload_file_name", filePath, RequestBody.create(JSON, file));
        }
        client.newCall(
                        getBiCiRequestBuilder(REQUEST_PREFIX, "/bluerider/lushu/import").post(addFormDataPart.build()).build())
                .enqueue(callback);
    }

    public static void searchLushu(Callback callback, String keyword, int searchType, int page, int limit) {
        HashMap hashMap = new HashMap();
        hashMap.put("keyword", keyword);
        hashMap.put("type", searchType);
        if (searchType == 2 || searchType == 7) {
            LatLng curLatLngWithMP = SharedManager.getInstance().getCurLatLngWithMP();
            hashMap.put("latitude", curLatLngWithMP.latitude);
            hashMap.put("longitude", curLatLngWithMP.longitude);
        }
        if (page >= 0 && limit > 0) {
            hashMap.put("pageNum", page);
            hashMap.put("pageSize", limit);
        }
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("/bluerider/lushu/lushu_search", hashMap))
                        .build();
        Log.d(TAG, "searchLushu:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static void searchLushuByStartEndPosition(Callback callback, int i, double d, double d2, double d3,
                                                     double d4, int pageNum, int pageSize) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("type", i);
        if (i == 4) {
            hashMap.put("startLatitude", d);
            hashMap.put("startLongitude", d2);
        } else if (i == 5) {
            hashMap.put("endLatitude", d3);
            hashMap.put("endLongitude", d4);
        } else if (i == 6) {
            hashMap.put("startLatitude", d);
            hashMap.put("startLongitude", d2);
            hashMap.put("endLatitude", d3);
            hashMap.put("endLongitude", d4);
        }

        if (pageNum > 0 && pageSize > 0) {
            hashMap.put("pageNum", pageNum);
            hashMap.put("pageSize", pageSize);
        }
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("/bluerider/lushu/lushu_search", hashMap))
                        .build();
        Log.d(TAG, "searchLushuByStartEndPosition:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call downloadRouteBookForWorkout(int type, long serverId) {
        String str;
        str = "download_workout/" + serverId + "/";

        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("version", 1);
        hashMap.put("credits", 1);
        hashMap.put("time", System.currentTimeMillis());
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams(str, hashMap)).build();
        Log.d(TAG, "downloadRouteBookForWorkout:" + build);
        return client.newCall(build);
    }

    public static void downloadRouteBook(Callback callback, int type, long serverId) {
        downloadRouteBook(type, serverId).enqueue(callback);
    }

    public static Call downloadRouteBook(int type, long serverId) {
        // if (type == TYPE_SOURCE_WORKOUT) {
        // return downloadRouteBookForWorkout(type, serverId);
        // }
        return downloadRouteBook(serverId);
    }

    public static Call downloadRouteBook(long serverId) {
        Request build = getMyRequestBuilder(REQUEST_PREFIX,
                buildUrlByParams("/bluerider/" + Constants.LUSHU_IMPORT + "download_lushu?serverId=" + serverId, null),
                true).build();
        Log.d(TAG, "downloadRouteBook:" + build);
        return client.newCall(build);
    }

    public static void downloadRouteBook(long serverId, Callback callback) {
        downloadRouteBook(serverId).enqueue(callback);
    }

    public static okhttp3.Response downloadRouteBookSync(long serverId) {
        try {
            return downloadRouteBook(serverId).execute();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static Call downloadRouteBookFile(long serverId) {
        Request build = getMyRequestBuilder(REQUEST_PREFIX,
                buildUrlByParams("/bluerider/lushu/download_lushu_file" + "?serverId=" + serverId, null), true).build();
        Log.d(TAG, "downloadRouteBookFile:" + build);
        return client.newCall(build);
    }

    public static void downloadRouteBookFile(long serverId, Callback callback) {
        Request build = getMyRequestBuilder(REQUEST_PREFIX,
                buildUrlByParams("/bluerider/lushu/download_lushu_file" + "?serverId=" + serverId, null), true).build();
        Log.d(TAG, "downloadRouteBookFile:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static okhttp3.Response downloadRouteBookFileSync(long serverId) {
        try {
            return downloadRouteBookFile(serverId).execute();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static void uploadMyLoation(Callback callback, LatLng latLng, DisplayPoint displayPoint, Workout workout,
                                       int status, float interval) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("latitude", latLng.latitude);
        hashMap.put("longitude", latLng.longitude);
        hashMap.put("timespan", interval);
        hashMap.put("status", status);
        if (displayPoint != null) {
            hashMap.put("speed", displayPoint.getSpeed(Utils.DOUBLE_EPSILON));
            hashMap.put("altitude", displayPoint.getAltitude(Utils.DOUBLE_EPSILON));
            hashMap.put("power", displayPoint.getPower(0.0f));
            hashMap.put("cadence", displayPoint.getCadence(0));
            hashMap.put("heartRate", displayPoint.getHeartrate(0));
        }
        if (workout != null) {
            hashMap.put("startTime", workout.getStartTime());
            hashMap.put("distance", workout.getDistance());
            hashMap.put("duration", workout.getDuration());
        }
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "/bluerider/workout/sync_new_location/")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "uploadMyLoation:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call uploadMyLoation(LatLng latLng, DisplayPoint displayPoint, Workout workout, int status,
                                       float interval) {
        return null;
    }

    public static Call updateSport(Workout workout) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverId", workout.getServerId());
        hashMap.put("sport", workout.getSport());
        hashMap.put("title", workout.getTitle());
        hashMap.put("hidden", workout.getHidden());
        hashMap.put("description", workout.getDescription());

        Request build = getBiCiRequestBuilderWithSportUpload(REQUEST_PREFIX, "bluerider/workout/update_workout")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "updateSport:" + build + " , " + build.headers());
        return client.newCall(build);
    }

    public static Call requestRankUserHot(int timeType, int areaId, int areaType, int sportType, int limit, int page) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("timeType", timeType);
        hashMap.put("cityId", areaId);
        hashMap.put("areaType", areaType);
        hashMap.put("sport", sportType);
        hashMap.put("pageSize", limit);
        hashMap.put("orderByColumn", "sumCredits");
        hashMap.put("isAsc", "desc");
        hashMap.put("pageNum", page);
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("bluerider/workout/rank_users_hot", hashMap))
                        .build();
        Log.d(TAG, "requestRankUserHot:" + build);
        return client.newCall(build);
    }

    public static Call requestPersonRank(int sport_type) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("sport", sport_type);
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("bluerider/workout/rank_list_user", hashMap))
                        .build();
        Log.d(TAG, "requestPersonRank:" + build);
        return client.newCall(build);
    }

    public static void deleteWorkout(Callback callback, long workoutId, int hideFlag) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverId", workoutId);
        hashMap.put("hidden", hideFlag);

        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "bluerider/workout/delete")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "deleteWorkout callback:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call deleteWorkout(long workoutId, int hideFlag) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverId", workoutId);
        hashMap.put("hidden", hideFlag);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "bluerider/workout/delete")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "deleteWorkout:" + build);
        return client.newCall(build);
    }

    public static Call getWorkoutComment(long workoutId, int page, int limit) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverId", workoutId);
        hashMap.put("page", page);
        hashMap.put(WorkoutContentProvider.QUERY_PARAM_LIMIT, limit);
        hashMap.put("time", System.currentTimeMillis());
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "bluerider/workout/workout_comment_xing/")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "getWorkoutComment: " + build);
        return client.newCall(build);
    }

    public static Call setWorkoutComment(long workoutId, String content, String photoUrl, long informedUserId) {
        HashMap hashMap = new HashMap();
        hashMap.put("serverId", workoutId);
        hashMap.put("content", content);
        if (informedUserId > 0) {
            hashMap.put("informedId", informedUserId);
        }
        hashMap.put("image", photoUrl);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "/bluerider/workout/workout_comment")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "setWorkoutComment:" + build);
        return client.newCall(build);
    }

    public static void getWorkoutLike(Callback callback, long workoutId) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverId", workoutId);
        hashMap.put("time", System.currentTimeMillis());
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("bluerider/workout/workout_like/", hashMap))
                        .get().build();
        Log.d(TAG, "getWorkoutLike: " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void hideWorkout(Callback callback, long workoutServerId, int hide) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverId", workoutServerId);
        hashMap.put("hidden", hide);

        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "bluerider/workout/hide")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "hide Workout callback:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call hideWorkout(long workoutServerId, int hide) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverId", workoutServerId);
        hashMap.put("hidden", hide);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "bluerider/workout/hide")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "hide Workout:" + build);
        return client.newCall(build);
    }

    public static void bindPhone(Callback callback, String phone, String code) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("phonenumber", phone);
        // hashMap.put("code", code);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "system/user/profile/third/phone/pwd")
                .put(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "bindPhone: " + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call uploadMobileLog(String fileName, String md5, OkUploadListener okUploadListener) {

        String uploadFileName = System.currentTimeMillis() + ".gz";

        // MultipartBody.Builder workoutBodyBuilder = getWorkoutBodyBuilder(workout);
        MultipartBody.Builder logBodyBuilder = new MultipartBody.Builder("bluebanklog").setType(MultipartBody.FORM);

        logBodyBuilder.addFormDataPart("upload_file_name", uploadFileName,
                RequestBody.create(MEDIA_TYPE_GZIP, new File(fileName))).addFormDataPart("md5File", md5);

        Request build = getBiCiRequestBuilderWithSportUpload(REQUEST_PREFIX, "bluerider/workout/upload_workout_log")
                .post(logBodyBuilder.build()).tag(okUploadListener).build();
        Log.d(TAG, "uploadMobileLog: " + build + " , " + build.headers());
        return client.newCall(build);
    }

    /**
     * 新建活动时上传图片
     *
     * @param eventId
     * @param fileName
     * @param md5
     * @param okUploadListener
     * @return
     */
    public static Call uploadEventPic(long eventId, String fileName, String md5, OkUploadListener okUploadListener) {
        MultipartBody.Builder logBodyBuilder = new MultipartBody.Builder("bbeventbb").setType(MultipartBody.FORM);
        String[] strs = fileName.split("/");
        String imageName = strs[strs.length - 1];
        logBodyBuilder
                .addFormDataPart("upload_file_name", imageName, RequestBody.create(MEDIA_TYPE_GZIP, new File(fileName)))
                .addFormDataPart("md5File", md5).addFormDataPart("eventId", String.valueOf(eventId));

        Request build = getBiCiRequestBuilderWithSportUpload(REQUEST_PREFIX, "bluerider/_event/upload/pic")
                .post(logBodyBuilder.build()).build();
        Log.d(TAG, "uploadEventPic: " + build + " , " + build.headers());
        return client.newCall(build);
    }

    public static Call uploadJsonSport(Workout workout, String fileName, String md5,
                                       OkUploadListener okUploadListener) {
        String dateString = DateUtil.format(System.currentTimeMillis(), 17);
        String uploadFileName = "w" + workout.getUserId() + "_" + workout.getUuid() + "_" + dateString + ".gz";

        // MultipartBody.Builder workoutBodyBuilder = getWorkoutBodyBuilder(workout);
        MultipartBody.Builder workoutBodyBuilder = new MultipartBody.Builder("lanxbike").setType(MultipartBody.FORM);

        //// workout.getCategory() != IWorkout.CATEGORY_MERGE &&

        if (workout.getLocSource() != Workout.LOCATION_SOURCE_XOSS_X2P && !TextUtils.isEmpty(md5)) {
            workoutBodyBuilder.addFormDataPart("upload_file_name", uploadFileName,
                    RequestBody.create(MEDIA_TYPE_GZIP, new File(fileName))).addFormDataPart("md5File", md5);
        }

        Request build = getBiCiRequestBuilderWithSportUpload(REQUEST_PREFIX, "bluerider/workout/upload_workout")
                .post(workoutBodyBuilder.build()).tag(okUploadListener).build();
        Log.d(TAG, "uploadJsonSport: " + build + " , " + build.headers());
        return client.newCall(build);
    }

    private static MultipartBody.Builder getWorkoutBodyBuilder(Workout workout) {
        WorkoutExtraInfo workoutExtraInfo = Workout.getWorkoutExtraInfo(workout.getId());
        String str = "";
        MultipartBody.Builder addFormDataPart = new MultipartBody.Builder("lanxbike").setType(MultipartBody.FORM)
                .addFormDataPart("distance", round(workout.getDistance()))// MonitoringReader.DISTANCE_STRING
                .addFormDataPart("downDistance", round(workout.getDownDistance()))
                .addFormDataPart("downDuration", String.valueOf(workout.getDownDuration()))
                .addFormDataPart("duration", String.valueOf(workout.getDuration()))
                .addFormDataPart("elevationGain", round(workout.getElevationGain()))
                .addFormDataPart("elevationLoss", round(workout.getElevationLoss()))
                .addFormDataPart("endTime", String.valueOf(workout.getEndTime()))
                .addFormDataPart("flatDistance", round(workout.getFlatDistance()))
                .addFormDataPart("flatDuration", String.valueOf(workout.getFlatDuration()))
                .addFormDataPart("hidden", String.valueOf(workout.getHidden()))
                .addFormDataPart("clientId", String.valueOf(workout.getId()))
                .addFormDataPart("lastUpload", String.valueOf(workout.getLastUpload()))
                .addFormDataPart("maxGrade", String.valueOf(workout.getMaxGrade()))
                .addFormDataPart("minGrade", String.valueOf(workout.getMinGrade()))
                .addFormDataPart("serverId", String.valueOf(workout.getServerId()))
                .addFormDataPart("sport", String.valueOf(workout.getSport()))// SettingSupports.SUPPORT_ITEM_SPORT
                .addFormDataPart("startTime", String.valueOf(workout.getStartTime()))
                .addFormDataPart("title", workout.getTitle() == null ? str : workout.getTitle())
                .addFormDataPart("description", workout.getDescription() == null ? str : workout.getDescription())
                .addFormDataPart("upDistance", round(workout.getUpDistance()))
                .addFormDataPart("upDuration", String.valueOf(workout.getUpDuration()))
                .addFormDataPart("uploadStatus", String.valueOf(workout.getUploadStatus()))
                .addFormDataPart("userId", String.valueOf(workout.getUserId()))
                .addFormDataPart("uuid", workout.getUuid() == null ? str : workout.getUuid())
                .addFormDataPart("maxCadence", String.valueOf(workout.getMaxCadence()))
                .addFormDataPart("avgCadence", String.valueOf(workout.getAvgCadence()))
                .addFormDataPart("startCadence", String.valueOf(workout.getStartCadence()))
                .addFormDataPart("endCadence", String.valueOf(workout.getEndCadence()))
                .addFormDataPart("maxHeartRate", String.valueOf(workout.getMaxHeartrate()))
                .addFormDataPart("avgHeartRate", String.valueOf(workout.getAvgHeartrate()))
                .addFormDataPart("startWheel", String.valueOf(workout.getStartWheel()))
                .addFormDataPart("endWheel", String.valueOf(workout.getEndWheel()))
                .addFormDataPart("maxWheelRpm", String.valueOf(workout.getMaxWheelRevolution()))
                .addFormDataPart("locSource", String.valueOf(workout.getLocSource()))
                .addFormDataPart("heartSource", String.valueOf(workout.getHeartSource()))
                .addFormDataPart("cadenceSource", String.valueOf(workout.getCadenceSource()))
                .addFormDataPart("segmentIndex", workout.getSegmentIndex() == null ? str : workout.getSegmentIndex())
                .addFormDataPart("segmentsKm", workout.getSegmentKMSample(350))
                .addFormDataPart("segmentsSport", workout.getSegmentSport() == null ? str : workout.getSegmentSport())
                .addFormDataPart("segmentsHr", workout.getSegmentHr() == null ? str : workout.getSegmentHr())
                .addFormDataPart("segmentsCa", workout.getSegmentCa() == null ? str : workout.getSegmentCa())
                .addFormDataPart("step", String.valueOf(workout.getStep()))
                .addFormDataPart("calorie", String.valueOf(workout.getCalorie()))
                .addFormDataPart("maxSpeed", String.valueOf(workout.getMaxSpeed()))
                .addFormDataPart("encodingPoints",
                        workout.getEncodingPoints() == null ? str : workout.getEncodingPoints())
                .addFormDataPart("maxAltitude", round(workoutExtraInfo.getMaxAltitude()))
                .addFormDataPart("avgAltitude", round(workoutExtraInfo.getAvgAltitude()))
                .addFormDataPart("powerMax", round(workout.getMaxPower()))
                .addFormDataPart("powerAvg", round(workout.getAvgPower()))
                .addFormDataPart("powerSource", String.valueOf(workout.getPowerSource()))
                .addFormDataPart("powerNP", String.valueOf(workout.getPowerNP()))
                .addFormDataPart("powerIF", String.valueOf(workout.getPowerIF()))
                .addFormDataPart("powerVI", String.valueOf(workout.getPowerVI()))
                .addFormDataPart("powerTSS", String.valueOf(workout.getPowerTSS()))
                .addFormDataPart("powerFTP", String.valueOf(workout.getPowerFTP()))
                .addFormDataPart("category", String.valueOf(workout.getCategory()));

        if (workout.getMergeRecord() != null) {
            str = workout.getMergeRecord();
        }
        return addFormDataPart.addFormDataPart("merge_record", str);
    }

    private static String round(double d) {
        return String.valueOf(Math.round(d));
    }

    public static void deleteDevice(int i) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("deviceId", i);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "delete_device")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "deleteDevice: " + build);
        client.newCall(build).enqueue(new BiCiCallback() {
            @Override
            public void onResponseString(@NonNull String str) throws JSONException {
            }
        });
    }

    public static void requestNearbyActivities(Callback callback, int page, int limit) {
        LatLng curLatLngWithMP = SharedManager.getInstance().getCurLatLngWithMP();
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("latitude", curLatLngWithMP.latitude);
        hashMap.put("longitude", curLatLngWithMP.longitude);

        hashMap.put("pageNum", page);
        hashMap.put("pageSize", limit);
        hashMap.put("isAsc", "desc");
        hashMap.put("orderByColumn", "eventId");// todo sst, should not be eventId, should be distance of my current
        // location

        Request build = getMyRequestBuilder(REQUEST_PREFIX,
                buildUrlByParams("bluerider/_event/get_nearby_activity", hashMap), false).get().build();
        Log.d(TAG, "requestNearbyActivities: " + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void requestMyActivities(Callback callback, int page, int limit, int locationSharing) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("pageNum", page);
        hashMap.put("pageSize", limit);
        hashMap.put("isAsc", "desc");
        hashMap.put("orderByColumn", "eventId");
        hashMap.put("locationSharing", locationSharing);

        String phone = App.getContext().getUserPhone();

        hashMap.put("phoneNumber", phone);

        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("bluerider/_event/get_my_activity", hashMap))
                        .get().build();
        Log.d(TAG, "requestMyActivities: " + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void requestActivityDetail(Callback callback, long eventId) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("eventId", eventId);

        String path = buildUrlByPath("bluerider/_event/", String.valueOf(eventId));
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, path).get().build();
        client.newCall(build).enqueue(callback);
    }

    public static void searchActivitys(Callback callback, String str, int page, int limit) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("keyword", str);

        hashMap.put("pageNum", page);
        hashMap.put("pageSize", limit);
        hashMap.put("isAsc", "desc");
        hashMap.put("orderByColumn", "eventId");

        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("bluerider/_event/search_activity", hashMap))
                        .get().build();

        // Request build = getBiCiRequestBuilder("v4/", buildUrlByParams("search_activity", hashMap)).build();
        Log.d(TAG, "searchActivitys: " + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call createActivity(Event event) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("title", event.getTitle());
        hashMap.put("level", event.getLevel());
        hashMap.put("description", event.getDescription());
        hashMap.put("startLat", event.getStartLat());
        hashMap.put("startLng", event.getStartLng());
        hashMap.put("cityId", event.getCityId());
        hashMap.put("startAddr", event.getStartAddr());
        hashMap.put("startTime", event.getStartTime());
        hashMap.put("endTime", event.getEndTime());
        hashMap.put("lushuId", event.getLushuId());
        hashMap.put("distance", (int) (event.getDistance() * 1000.0d));
        hashMap.put("cost", event.getCost());
        hashMap.put("phoneNumber", event.getPhoneNumber());
        hashMap.put("memberLimit", event.getMemberLimit());
        hashMap.put("photoUrl", event.getPhotoUrl());
        hashMap.put("memberCount", 1);
        hashMap.put("ownerApprove", event.getOwnerApprove());
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "bluerider/_event")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "createActivity: " + "request : " + build);
        return client.newCall(build);
    }

    public static void shareLocation(Callback callback, long eventId, String phoneNumber, int locationSharing) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("eventId", eventId);
        hashMap.put("phoneNumber", phoneNumber);
        hashMap.put("locationSharing", locationSharing);

        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "/bluerider/_eventer/share_location")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "shareLocation: " + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void joinActivity(Callback callback, long eventId, String phoneNumber) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("eventId", eventId);
        hashMap.put("phoneNumber", phoneNumber);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "/bluerider/_eventer/join_activity")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "joinActivity: " + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void approveActivity(Callback callback, long eventId, String phoneNumber, int status) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("eventId", eventId);
        hashMap.put("phoneNumber", phoneNumber);
        hashMap.put("status", status);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "/bluerider/_eventer/approve_activity")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "approveActivity: " + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void quitActivity(Callback callback, long eventId, String phoneNumber) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("eventId", eventId);
        hashMap.put("phoneNumber", phoneNumber);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "/bluerider/_eventer/quit_activity")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "quitActivity: " + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void deleteActivity(Callback callback, long eventId) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("eventId", eventId);

        String path = buildUrlByPath("bluerider/_event/", String.valueOf(eventId));
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, path).delete().build();
        client.newCall(build).enqueue(callback);

        // Request build = getBiCiRequestBuilder("v4/", "delete_activity").post(RequestBody.create(JSON,
        // buildSimpleJson(hashMap))).build();
        // Log.d(TAG, "deleteActivity: " + "request : " + build);
        // client.newCall(build).enqueue(callback);
    }

    public static void signout() {
        Request build = getBiCiRequestBuilder("prod-api/", "logout").build();
        Log.d(TAG, "signout: " + "request : " + build);
        client.newCall(build).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, @NonNull IOException iOException) {
                Log.e(TAG, "signout: onFailure : " + iOException.getMessage());
            }

            @Override
            public void onResponse(Call call, okhttp3.Response response) throws IOException {
                String string = response.body().string();
                Log.d(TAG, "signout: response : " + response + " body : " + string);
            }
        });
    }

    public static void requestLaunchVersionInfo(Callback callback, long j) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("os", "android");
        hashMap.put("temp", System.currentTimeMillis());
        hashMap.put("version", Build.VERSION.RELEASE);
        hashMap.put("s_version", App.getContext().getVersionName());
        if (j > 0) {
            hashMap.put("p_id", j);
        }
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("v3_version", hashMap)).build();
        Log.d(TAG, "requestLaunchVersionInfo: " + "request : " + build);
        // client.newCall(build).enqueue(callback);///sst todo, will open later

    }

    public static void register(Callback callback, int ltype, String phone, int keycode, String password) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("ltype", ltype);
        if (ltype == 0) {
            hashMap.put("phone", phone);
            hashMap.put("username", phone);
            hashMap.put("code", keycode);
        } else {
            hashMap.put("email", phone);
        }
        // String encode = RSAUtil.encode(str2 + ";clin");
        // if (TextUtils.isEmpty(encode)) {
        // App.getContext().showMessage("密码加密失败。");
        // return;
        // }
        hashMap.put("password", password);
        // hashMap.put(SocialConstants.PARAM_SOURCE, Build.BRAND + " , " + Build.MODEL);
        Request build = getMyRequestBuilder(REQUEST_PREFIX, "mobile/register", false)
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "register: " + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void accountNumLogin(Callback callback, String userName, String password) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("username", userName);
        hashMap.put("password", password);

        Request build = getMyRequestBuilder(REQUEST_PREFIX, "mobile/login", false)
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "accountNumLogin: " + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call accountNumLogin(String userName, String password) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("username", userName);

        hashMap.put("password", password);

        Request build = getMyRequestBuilder(REQUEST_PREFIX, "mobile/login", false)
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "accountNumLogin: " + "request : " + build);
        return client.newCall(build);
    }

    public static Call accountSmsLogin(String phone, String code) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("open_id", phone);
        hashMap.put("ltype", 3);
        hashMap.put("code", code);

        Request build = getMyRequestBuilder(REQUEST_PREFIX, "sms/login", false)
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "accountSmsLogin: " + "request : " + build);
        return client.newCall(build);
    }

    public static void bindAccount(Callback callback, String phone, int keyCode, String pwd) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("phonenumber", phone);
        hashMap.put("salt", keyCode);
        // if (Validator.isPhoneNumber(phone)) {
        // hashMap.put("keycode", keyCode);
        // }

        // String encode = RSAUtil.encode(str2 + ";clin");
        // if (TextUtils.isEmpty(encode)) {
        // App.getContext().showMessage("密码加密失败。");
        // return;
        // }
        hashMap.put("password", pwd);
        // hashMap.put(SocialConstants.PARAM_SOURCE, Build.BRAND + " , " + Build.MODEL);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "system/user/profile/third/phone/pwd")
                .put(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "bindAccount: " + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void forgetPwd(Callback callback, String phone, int keyCode, String pwd) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("phonenumber", phone);
        hashMap.put("salt", keyCode);
        hashMap.put("password", pwd);
        Request build = getMyRequestBuilder(REQUEST_PREFIX, "mobile/forget_pwd", false)
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "bindAccount: " + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void userSigninByThirdParty(Callback callback, JSONObject jSONObject) {
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "third/login")
                .post(RequestBody.create(JSON, jSONObject.toString())).build();
        Log.d(TAG, "userSigninByThirdParty: " + " jsonObject = " + jSONObject);
        Log.d(TAG, "userSigninByThirdParty: " + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call userSigninByThirdParty(JSONObject jSONObject) {
        Request build = getMyRequestBuilder(REQUEST_PREFIX, "third/login", false)
                .post(RequestBody.create(JSON, jSONObject.toString())).build();
        Log.d(TAG, "userSigninByThirdParty: " + " jsonObject = " + jSONObject);
        Log.d(TAG, "userSigninByThirdParty: " + build);
        return client.newCall(build);
    }

    public static Call getUserInfo(long j) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("userId", j);
        hashMap.put("timestamp", System.currentTimeMillis());
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("account/get_user_info", hashMap)).get().build();
        Log.d(TAG, "getUserInfo: " + "request : " + build);
        return client.newCall(build);
    }

    public static void updateUserInfo(Callback callback, Map<String, Object> map) {
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "account/update_user_info")
                .post(RequestBody.create(JSON, buildSimpleJson(map))).build();
        Log.d(TAG, "updateUserInfo: " + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void updateUserSetting(Callback callback, Map<String, Object> map) {
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "account/update_user_settings")
                .post(RequestBody.create(JSON, buildSimpleJson(map))).build();
        Log.d(TAG, "updateUserSetting: " + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void bindThirdParty(Callback callback, JSONObject jSONObject) {
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "account/third_party_bind")
                .post(RequestBody.create(JSON, jSONObject.toString())).build();
        Log.d(TAG, "bindThirdParty: " + "bindThirdParty jsonObject = " + jSONObject);
        Log.d(TAG, "bindThirdParty: " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void unbindThirdParty(Callback callback, int ltype) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("ltype", ltype);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "account/third_party_unbind")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "unbindThirdParty: " + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call slopeInfo(long j) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("timestamp", System.currentTimeMillis());
        Request build = getBiCiRequestBuilder("prod-api",
                buildUrlByParams("bluerider/workout/pgworkout/" + j + "/slope", hashMap)).build();
        Log.d(TAG, "slopeInfo: " + "request : " + build);
        return client.newCall(build);
    }

    public static Call segmentWorkout(long workoutServerId) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverId", workoutServerId);
        hashMap.put("timestamp", System.currentTimeMillis());
        Request build = getBiCiRequestBuilder("prod-api/", "bluerider/workout/segment_workout/")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "segmentWorkout: " + "request : " + build);
        return client.newCall(build);
    }

    public static Call segmentLike(long serverId, boolean like) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverId", serverId);
        hashMap.put("isLike", like ? 1 : 0);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "bluerider/workout/workout_like/")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "segmentLike:" + "request : " + build);
        return client.newCall(build);
    }

    public static Call createRouteBookByWorkoutId(long j) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("serverId", j);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "bluerider/lushu/from_workout/")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "createRouteBookByWorkoutId:" + "request : " + build);
        return client.newCall(build);
    }

    public static Call segmentWorkoutPoints(long j) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("timestamp", System.currentTimeMillis());// UMCrash.SP_KEY_TIMESTAMP
        Request build = getBiCiRequestBuilder("prod-api/",
                buildUrlByParams("bluerider/workout/pgworkout/" + j + "/points/", hashMap)).build();
        String sb = "request : " + build;
        Log.d(TAG, "segmentWorkoutPoints: " + sb);
        return client.newCall(build);
    }

    // line 2459
    public static Call uploadClientId(long j, String str) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put(com.tencent.connect.common.Constants.PARAM_CLIENT_ID, str);
        hashMap.put("user_id", j);
        hashMap.put("os", "android");
        return client.newCall(getBiCiRequestBuilder(REQUEST_PREFIX, "sync_gt_cid")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build());
    }

    public static Call updateNotificationSwitchStatus(String str) {
        return client.newCall(
                getBiCiRequestBuilder(REQUEST_PREFIX, "gt_switch").post(RequestBody.create(JSON, str)).build());
    }

    public static Call requestNotificationSwitchStatus() {
        return client.newCall(getBiCiRequestBuilder(REQUEST_PREFIX, "gt_switch").get().build());
    }

    public static Call requestAreaData() {
        return client.newCall(new Request.Builder()
                .url("https://woc.bluebank.com.cn/prod-api/address/area/area_zh.json").get().build());
    }

    public static Call unRegister(@NonNull String phone, int keycode) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("username", phone);
        hashMap.put("code", keycode);
        Request build = getMyRequestBuilder(REQUEST_PREFIX, "unregister", true)
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        return client.newCall(build);
    }

    public static Call requestLogout() {
        return client.newCall(
                getBiCiRequestBuilder(REQUEST_PREFIX, "user/delete/").post(new FormBody.Builder().build()).build());
    }

    /**
     * 发送短信验证码
     *
     * @param mobile
     * @return
     */
    public static Call requestAuthcode(@NonNull String mobile, int i, int i2, long j) {
        Request build = getMyRequestBuilder(REQUEST_PREFIX, "send/sms/code/" + mobile, false).get().build();
        Log.d(TAG, "requestAuthcode: " + "request : " + build);
        return client.newCall(build);
    }

    public static Call bindTencentIM(String phone) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("phonenumber", phone);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "/system/user/profile/bind/tencent/im")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "bindTencentIM: " + "request : " + build);
        return client.newCall(build);
    }

    public static void forget_pwd(Callback callback, String phone, int keyCode, String pwd) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("phonenumber", phone);
        hashMap.put("salt", keyCode);

        hashMap.put("password", pwd);
        // hashMap.put(SocialConstants.PARAM_SOURCE, Build.BRAND + " , " + Build.MODEL);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "mobile/forget_pwd")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "bindAccount: " + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call uploadAvatar(File file) {
        RequestBody requestBody = RequestBody.create(MultipartBody.FORM, file);
        MultipartBody.Builder builder = new MultipartBody.Builder();
        builder.addFormDataPart("avatarfile", file.getName(), requestBody);
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, "/system/user/profile/_avatar").post(builder.build()).build();
        Log.d(TAG, "uploadAvatar request : " + build);
        return client.newCall(build);
    }

    /**
     * 获取 发现页 帮助内容
     * type 0 advertise   1 courseware  2 other
     *
     * @return
     */
    public static Call requestGetDiscoveryHelp(int pageNum, int pageSize, int listType) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("pageNum", pageNum);
        hashMap.put("pageSize", pageSize);
        hashMap.put("type", listType);
        hashMap.put("isAsc", "asc");
        hashMap.put("orderByColumn", "sort");
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("website/banner/bluerider/list", hashMap)).get()
                        .build();
        Log.d(TAG, "requestGetDiscoveryHelp: " + " request : " + build);
        return client.newCall(build);
    }

    public static void postUserCard(Callback callback, UserCard userCard) {
        HashMap<String, Object> hashMap = new HashMap<>();
        if (userCard.getCardId() > 0) {
            hashMap.put("cardId", userCard.getCardId());
        }
        hashMap.put("name", userCard.getName());
        hashMap.put("cardNo", userCard.getCardNo());
        hashMap.put("gender", userCard.getGender());
        hashMap.put("birthday", userCard.getBirthday());
        hashMap.put("phone", userCard.getPhone());
        hashMap.put("email", userCard.getEmail());
        hashMap.put("address", userCard.getAddress());
        hashMap.put("contactName", userCard.getContactName());
        hashMap.put("contactPhone", userCard.getContactPhone());
        hashMap.put("province", userCard.getProvince());
        hashMap.put("city", userCard.getCity());
        hashMap.put("area", userCard.getArea());
        hashMap.put("addressDetail", userCard.getAddressDetail());
        Request build = getBiCiRequestBuilder("prod-api/", "uniaccount/userEntryCard/update")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "postUserCard: " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void requestUserCard(Callback callback) {
        Request build = getBiCiRequestBuilder("prod-api/", "uniaccount/userEntryCard/get").get().build();
        client.newCall(build).enqueue(callback);
    }

    public static Call uploadLog(String type, String fileName, String md5, String phone) {
        String suffix = Paths.get(fileName).getFileName().toString();
        String uploadFileName = type + "_" + phone + "_" + DateUtil.format(System.currentTimeMillis()) + "_" + suffix;
        // MultipartBody.Builder workoutBodyBuilder = getWorkoutBodyBuilder(workout);
        MultipartBody.Builder logBodyBuilder = new MultipartBody.Builder("bluebanklog").setType(MultipartBody.FORM);

        logBodyBuilder.addFormDataPart("upload_file_name", uploadFileName,
                RequestBody.create(MEDIA_TYPE_GZIP, new File(fileName))).addFormDataPart("md5File", md5);

        Request build = getBiCiRequestBuilderWithSportUpload(REQUEST_PREFIX, "bluerider/workout/upload_workout_log")
                .post(logBodyBuilder.build()).build();
        Log.d(TAG, "uploadLog: " + build + " , " + build.headers());
        return client.newCall(build);
    }

    public static Call getNewestVersion() {
        Request build = getMyRequestBuilder(REQUEST_PREFIX, "fota/" + PROJECT_NAME + "/getNewestVersion/", false).get().build();
        Log.d(TAG, "getNewestVersion: " + " request : " + build);
        return client.newCall(build);
    }

    public static void getNewWatchVersion(Callback callback, String currentVerNum) {
        HashMap hashMap = new HashMap();
        hashMap.put("softname", PROJECT_NAME);
        hashMap.put("vername", currentVerNum);
        hashMap.put("target", MsgStrAnalyzer.mMacAddress);
        Request build = getMyRequestBuilder(REQUEST_PREFIX, buildUrlByParams("fota/getNewVersion/", hashMap), false)
                .get().build();
        Log.d(TAG, "getNewVersion: " + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void downloadNewestWatchVersion(Callback callback, String url) {
        Request build = new Request.Builder().addHeader("Range", "bytes=0-").url(url).build();
        Log.d(TAG, "downloadNewestWatchVersion: " + " request : " + build);
        client.newCall(build).enqueue(callback);
    }

    /**
     * 获取论坛列表
     * <p>
     * param callback
     *
     * @param page
     * @param limit
     */
    public static void requestBbsList(Callback callback, int page, int limit, int typeId, int userId) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("pageNum", page);
        hashMap.put("pageSize", limit);
        if (typeId != 0) {
            hashMap.put("typeId", typeId);
        }
        hashMap.put("userId", userId);

        Request build = getMyRequestBuilder(REQUEST_PREFIX, buildUrlByParams("cms/forum/cms/cmsList", hashMap), false)
                .get().build();
        Log.d(TAG, "requestBbsList: " + " request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call createBbs(Bbs bbs) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("title", "hello title");
        hashMap.put("content", bbs.content);
        hashMap.put("typeIds", bbs.typeList);
        String body = com.alibaba.fastjson.JSON.toJSONString(hashMap);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "cms/forum").post(RequestBody.create(JSON, body)).build();
        Log.d(TAG, "createBbs: " + "request : " + build);
        return client.newCall(build);
    }

    public static Call deleteBbs(int bbsId) {
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "cms/forum/" + bbsId).delete().build();
        Log.d(TAG, "deleteBbs: " + "request : " + build);
        return client.newCall(build);
    }

    /**
     * 发布帖子时上传图片
     *
     * @param fileName
     * @param md5
     * @param okUploadListener
     * @return
     */
    public static Call uploadBbsPic(String fileName, String md5, OkUploadListener okUploadListener) {
        MultipartBody.Builder logBodyBuilder = new MultipartBody.Builder("bbeventbb").setType(MultipartBody.FORM);
        String[] strs = fileName.split("/");
        String imageName = strs[strs.length - 1];
        logBodyBuilder
                .addFormDataPart("upload_file_name", imageName, RequestBody.create(MEDIA_TYPE_GZIP, new File(fileName)))
                .addFormDataPart("md5File", md5);

        Request build = getBiCiRequestBuilderWithSportUpload(REQUEST_PREFIX, "cms/forum/upload_image")
                .post(logBodyBuilder.build()).build();
        Log.d(TAG, "uploadBbsPic: " + build + " , " + build.headers());
        return client.newCall(build);
    }

    public static Call attachBbsPic(int serverId, List<Long> imageServerIdlist) {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("id", serverId);
            JSONArray jsonArray = new JSONArray();
            for (Long id : imageServerIdlist) {
                jsonArray.put(id);
            }
            jSONObject.put("fileIds", jsonArray);
        } catch (Exception e) {
            e.printStackTrace();
            if (App.getContext().isDebugMode()) {
                App.getContext().showMessage("httpclient build json error ！！！");
            }
        }
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "cms/forum/batchFiles")
                .post(RequestBody.create(JSON, jSONObject.toString())).build();
        Log.d(TAG, "attachBbsPic: " + "request : " + build);
        return client.newCall(build);
    }

    /**
     * 获取帖子类型列表
     *
     * @param callback
     */
    public static void getForumTypeList(Callback callback) {
        Request build = getMyRequestBuilder(REQUEST_PREFIX, "cms/forum/typeList", false).get().build();
        Log.d(TAG, "getForumTypeList: " + " request : " + build);
        client.newCall(build).enqueue(callback);
    }

    /**
     * 获取论坛评论列表
     * <p>
     * param callback
     *
     * @param page
     * @param limit
     */
    public static void requestBbsCommentList(Callback callback, int bbsId, int page, int limit, int userId) {
        String url = "cms/forum/get_blog_comment/" + bbsId;
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("pageNum", page);
        hashMap.put("pageSize", limit);
        hashMap.put("userId", userId);
        Request build = getMyRequestBuilder(REQUEST_PREFIX, buildUrlByParams(url, hashMap), false).get().build();
        Log.d(TAG, "requestBbsCommentList: " + " request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call createBbsComment(int bbsId, String content) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("blogId", bbsId);
        hashMap.put("content", content);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "cms/forum/comment")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "createBbsComment: " + "request : " + build);
        return client.newCall(build);
    }

    public static Call commitBbslike(int bbsId, int isLike) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("id", bbsId);
        hashMap.put("isLike", isLike);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "cms/forum/like")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "commitBbslike: " + "request : " + build);
        return client.newCall(build);
    }

    public static Call commitCommentlike(int commentId, int isLike) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("id", commentId);
        hashMap.put("likeNum", isLike);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "cms/forum/commentLike")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "commitCommentlike: " + "request : " + build);
        return client.newCall(build);
    }

    public static Call deleteComment(int commentId) {
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "cms/comment/" + commentId).delete().build();
        Log.d(TAG, "deleteComment: " + "request : " + build);
        return client.newCall(build);
    }

    public static void requestReportTypeList(Callback callback) {
        Request build = getMyRequestBuilder(REQUEST_PREFIX, "cms/forum/ReportTypeList", false).get().build();
        Log.d(TAG, "getForumTypeList: " + " request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call commitReport(int typeId, int blogId, int commentId, String content) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("typeId", typeId);
        hashMap.put("blogId", blogId);
        hashMap.put("commentId", commentId);
        hashMap.put("content", content);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "cms/forum/report")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "commitReport: " + "request : " + build);
        return client.newCall(build);
    }

    /**
     * 路书收藏
     *
     * @param j 路书id
     * @param i 1 删除, 0 添加
     * @return
     */
    public static Call lushuCollectionControl(long j, int i) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("lushuId", j);
        if (i == 1) {
            hashMap.put("action", "delete");
        } else if (i == 0) {
            hashMap.put("action", "add");
        }
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "/bluerider/lushu/lushu_collect")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "lushuCollectionControl:" + build);
        return client.newCall(build);
    }

    ////// following is stub function , useless now

    public static Call getPopwindowInfo() {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("t", System.currentTimeMillis());
        return client.newCall(getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("pop/window/", hashMap)).build());
    }

    public static void userBindThirdParty(Callback callback, String str, String str2) {
        Request build = getBiCiRequestBuilder("third_party_bind")
                .post(new FormBody.Builder().add("account", str).add("user_info", str2).build()).build();
        Log.d(TAG, "userBindThirdParty:" + "account = " + str);
        Log.d(TAG, "userBindThirdParty:" + "user_info = " + str2);
        Log.d(TAG, "userBindThirdParty:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static void unbindAccount(Callback callback, int i) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("account_type", i);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "account/unbind/")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "unbindAccount:" + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    // useless now
    public static Call addUserAvatorMedalPendant(long j, int i) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("mid", j);
        hashMap.put("offset", i);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "medal_avatar_set")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "addUserAvatorMedalPendant:" + "request : " + build);
        return client.newCall(build);
    }

    public static void uploadDevice(Callback callback, Device device) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("deviceAddr", device.getAddress());
        hashMap.put("deviceType", device.getType());
        hashMap.put("deviceName", device.getName());
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "upload_device")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "uploadDevice:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static void uploadDeviceToken(String deviceToken) {
        HashMap hashMap = new HashMap();
        hashMap.put("token"/* AssistPushConsts.MSG_TYPE_TOKEN */, deviceToken);
        hashMap.put(SocializeProtocolConstants.PROTOCOL_KEY_REQUEST_TYPE, 2);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "post/device/token")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "uploadDeviceToken:" + build);
        client.newCall(build).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException iOException) {
            }

            @Override
            public void onResponse(Call call, okhttp3.Response response) throws IOException {
                Log.d(TAG, response + " , " + response.body().string());
            }
        });
    }

    static Request.Builder getMyRequestBuilder(String str) {
        return getBiCiRequestBuilder(REQUEST_PREFIX, str);
    }

    public static void uploadLushu2AliOss(Callback callback, String str, String str2, String str3, String str4,
                                          String str5, String str6) {
        MultipartBody.Builder addFormDataPart =
                new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("OSSAccessKeyId", str2);
        MultipartBody.Builder addFormDataPart2 = addFormDataPart.addFormDataPart("key", "lushu-" + str6)
                .addFormDataPart("Signature", str3).addFormDataPart(/* an.bp */"policy", str4);
        if (!TextUtils.isEmpty(str5)) {
            addFormDataPart2.addFormDataPart(DeepLinkPathConstants.SCHEME_FILE, str6,
                    RequestBody.create(JSON, new File(str5 + str6)));
        }
        Request build = getMyRequestBuilder(str).post(addFormDataPart2.build()).build();
        Log.d("uploadLushu2AliOss", build + " , " + build.headers());
        client.newCall(build).enqueue(callback);
    }

    public static void getRouteBookToken(Callback callback, String str) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put(/* c.b */"biz", "lushu");
        hashMap.put(/* TypedValues.AttributesType.S_TARGET */"target", "lushu-" + str);
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("common/aliyun/sts_token/", hashMap)).build();
        Log.d(TAG, "getRouteBookToken:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static void requestElevation(Callback callback, double latitude, double longitude) {
        ArrayList arrayList = new ArrayList(1);
        arrayList.add(new GeoPoint(IGeoPoint.TYPE_EARTH, latitude, longitude));
        requestGeoElevations(callback, arrayList);
    }

    public static void requestGeoElevations(Callback callback, List<IGeoPoint> points) {
        HashMap hashMap = new HashMap();
        hashMap.put("encode_str", PolylineUtil.encodeGeo(points));
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "elevation/")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "requestGeoElevations:" + build);
        client.newCall(build).enqueue(callback);
    }

    @Deprecated
    public static void requestEventAndClubList(Callback callback) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("time", System.currentTimeMillis());
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("get_team_activity_lists", hashMap)).build();
        Log.d(TAG, "requestEventAndClubList:" + build);
        client.newCall(build).enqueue(callback);
    }

    @Deprecated
    public static void requestMembersLocation(Callback callback, long j, int i) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("id", String.valueOf(j));
        hashMap.put("type", String.valueOf(i));
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("get_members_location", hashMap)).build();
        Log.d(TAG, "requestMembersLocation:" + build);
        client.newCall(build).enqueue(callback);
        cleanCache();
    }

    public static Call requestClubRank() {
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("rank_list_team/", null)).build();
        Log.d(TAG, "requestClubRank:" + build);
        return client.newCall(build);
    }

    public static void payByAlipay(Callback callback, String str) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("orderId", str);
        hashMap.put("type", 1);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("competition_order", hashMap)).build();
        Log.d(TAG, "payByAlipay:" + "request : " + build);
        client.newCall(build).enqueue(callback);
        cleanCache();
    }

    public static void payByWechat(Callback callback, String str) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("orderId", str);
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("competition_order_weixin", hashMap)).build();
        Log.d(TAG, "payByWechat:" + "request : " + build);
        client.newCall(build).enqueue(callback);
        cleanCache();
    }

    public static void webShareStatistics(Callback callback, String str) {
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "link/share/")
                .post(new FormBody.Builder().add("link", str).build()).build();
        client.newCall(build).enqueue(callback);
        Log.d(TAG, "webShareStatistics:" + "request : " + build);
    }

    public static void requestMineMedal(Callback callback, int i, int i2) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put(WorkoutContentProvider.QUERY_PARAM_LIMIT, i);
        hashMap.put("page", i2);
        hashMap.put("time", System.currentTimeMillis());
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("get_user_medals", hashMap)).build();
        Log.d(TAG, "requestMineMedal:" + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call slopePointsInfo(long j, int i) {
        String str = i == 0 ? "low" : "high";
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put(/* UMCrash.SP_KEY_TIMESTAMP */"timestamp", System.currentTimeMillis());
        hashMap.put(MapBundleKey.MapObjKey.OBJ_LEVEL, str);
        return client.newCall(
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("pgworkout/" + j + "/slope_points/", hashMap))
                        .build());
    }

    public static Call hideMapWorkout(long workoutId, int hide) {
        HashMap hashMap = new HashMap();
        hashMap.put("id", workoutId);
        hashMap.put("action", hide);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "workout_action")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "hideMapWorkout:" + build);
        return client.newCall(build);
    }

    static Request.Builder getBiCiRequestBuilder(String str, HashMap<String, Object> hashMap) {
        return getBiCiRequestBuilder(buildUrlByParams(str, hashMap));
    }

    public static Call getHeatRecordForDate(String date) {
        HashMap hashMap = new HashMap();
        hashMap.put("t", System.currentTimeMillis());
        if (date != null) {
            hashMap.put("date", date);
        }
        Request build = getBiCiRequestBuilder("heat/user/", hashMap).build();
        Log.d(TAG, "getHeatRecordForDate:" + build);
        return client.newCall(build);
    }

    public static Call getWorkoutLap(long workoutId, long lushuId) {
        HashMap hashMap = new HashMap();
        hashMap.put("workoutId", workoutId);
        if (lushuId > 0) {
            hashMap.put(SportActivity.EXTRA_LUSHU_ID, lushuId);
        }
        Request build = getBiCiRequestBuilder("segment_workout_loop/", hashMap).build();
        Log.d(TAG, "getWorkoutLap:" + build);
        return client.newCall(build);
    }

    public static Call segmentMineGrade(long j, long j2, int i, int i2) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("user_id", j);
        hashMap.put(WorkoutContentProvider.QUERY_PARAM_LIMIT, i2);
        hashMap.put("page", i);
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("segment_my_list/" + j2 + "/", hashMap)).build();
        StringBuilder sb = new StringBuilder();
        sb.append("request : ");
        sb.append(build);
        Log.d(TAG, "segmentMineGrade:" + sb);
        return client.newCall(build);
    }

    public static Call segmentRank(int i, long j, int i2, int i3, long j2) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("type", i);
        hashMap.put(SportActivity.EXTRA_LUSHU_ID, j);
        hashMap.put(WorkoutContentProvider.QUERY_PARAM_LIMIT, i3);
        hashMap.put("page", i2);
        if (j2 > 0) {
            hashMap.put("user_id", j2);
        }
        return client
                .newCall(getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("new_segment_rank/", hashMap)).build());
    }

    public static Call segmentInfo(long j, long j2) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put(SportActivity.EXTRA_LUSHU_ID, j);
        hashMap.put("workout_id", j2);
        hashMap.put(/* UMCrash.SP_KEY_TIMESTAMP */"timestamp", System.currentTimeMillis());
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("new_segment_info/", hashMap)).build();
        Log.d(TAG, "segmentInfo:" + "request : " + build);
        return client.newCall(build);
    }

    public static Call segmentMine(int i, int i2) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put(WorkoutContentProvider.QUERY_PARAM_LIMIT, i2);
        hashMap.put("page", i);
        hashMap.put("version", 1);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("segment_my/", hashMap)).build();
        Log.d(TAG, "segmentMine:" + "request : " + build);
        return client.newCall(build);
    }

    public static Call thirdAdShowOrClick(String str) {
        return client.newCall(getThirdRequestBuilder(str, "").build());
    }

    static Request.Builder getThirdRequestBuilder(String str, String str2) {
        if (client == null) {
            init(null);
        }
        Request.Builder builder = new Request.Builder();
        return builder.url(str + str2).header("User-Agent", userAgent).addHeader("Accept", "application/json")
                .addHeader("Content-type", "application/json");
    }

    public static void uploadBiciLocation(Callback callback, LatLng latLng) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("deviceLat", (int) (latLng.latitude * 1000000.0d));
        hashMap.put("deviceLon", (int) (latLng.longitude * 1000000.0d));
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "bc/upload_loc")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "uploadBiciLocation:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call uploadFitWorkout(Workout workout, OkUploadListener okUploadListener) {
        File file = new File(workout.getFitPath());
        String md5 = CommonUtil.getMD5(file);
        String str = System.currentTimeMillis() + ".fit";
        MultipartBody.Builder type = new MultipartBody.Builder(Constants.FIT_DIR).setType(MultipartBody.FORM);
        if (workout.getTitle() == null) {
            workout.setTitle(WorkoutTitleUtil.buildWorkoutDefaultTitle(App.getContext(), workout));
        }
        if (workout.getDescription() == null) {
            workout.setDescription("");
        }
        type.addFormDataPart("name", workout.getTitle()).addFormDataPart("detail", workout.getDescription())
                .addFormDataPart("fit_filename", str)
                .addFormDataPart("fit_file", str, RequestBody.create(MEDIA_TYPE_OCTET_STREAM, file))
                .addFormDataPart("md5", md5);
        // Request build = getBiCiRequestBuilder(VERSION_1,
        // "fit/upload/").post(type.build()).tag(OkUploadListener.class, okUploadListener).build();//todo sst , how to
        // use okUploadListener
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, "fit/upload/").post(type.build()).tag(okUploadListener).build();
        Log.d(TAG, "uploadFitWorkout:" + build);

        Call call = client.newCall(build);
        call.cancel();
        return call;
    }

    public static Call getBikePlaceInfo(LatLng latLng, int page, int limit, int action) {
        HashMap hashMap = new HashMap();
        hashMap.put("latitude", latLng.latitude);
        hashMap.put("longitude", latLng.longitude);
        hashMap.put("page", page);
        hashMap.put(WorkoutContentProvider.QUERY_PARAM_LIMIT, limit);
        hashMap.put("action", action);
        Request build = getBiCiRequestBuilder("service_point", hashMap).build();
        Log.d(TAG, "getBikePlaceInfo:" + build);
        return client.newCall(build);
    }

    public static Call requestEventAndClubList() {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("time", System.currentTimeMillis());
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("get_team_activity_lists", hashMap)).build();
        Log.d(TAG, "requestEventAndClubList:" + build);
        return client.newCall(build);
    }

    public static void requestElevation(Callback callback, LatLng latLng) {
        ArrayList<LatLng> arrayList = new ArrayList<>(1);
        arrayList.add(latLng);
        requestElevations(callback, arrayList);
    }

    public static void requestElevations(Callback callback, List<LatLng> latLngList) {
        HashMap hashMap = new HashMap();
        hashMap.put("encode_str", PolylineUtil.encode(latLngList));
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "elevation/")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "requestElevations:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call requestElevation(LatLng earth) {
        ArrayList arrayList = new ArrayList(1);
        arrayList.add(earth);
        return requestElevations(arrayList);
    }

    public static Call requestElevations(List<LatLng> latLngList) {
        HashMap hashMap = new HashMap();
        hashMap.put("encode_str", PolylineUtil.encode(latLngList));
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "elevation/")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "requestElevations:" + build);
        return client.newCall(build);
    }

    public static Call requestMembersLocation(long j, int i) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("id", String.valueOf(j));
        hashMap.put("type", String.valueOf(i));
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("get_members_location", hashMap)).build();
        Log.d(TAG, "requestMembersLocation:" + build);
        Call newCall = client.newCall(build);
        cleanCache();
        return newCall;
    }

    public static Call getBikePlaceDetail(int bikePlaceId, int action, int types) {
        HashMap hashMap = new HashMap();
        hashMap.put("sp_id", bikePlaceId);
        hashMap.put("action", action);
        hashMap.put("types", types);
        Request build = getBiCiRequestBuilder("service_point", hashMap).build();
        Log.d(TAG, "getBikePlaceDetail:" + build);
        return client.newCall(build);
    }

    public static void uploadIndoorCycling(Callback callback, Workout workout) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("title", workout.getTitle());
        hashMap.put("detail", workout.getDescription());
        RequestBody create = RequestBody.create(JSON, buildSimpleJson(hashMap));
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, "pgworkout/" + workout.getServerId() + "/").patch(create).build();
        Log.d(TAG, "uploadIndoorCycling:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call requestWorkoutTo3D(long j) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("credits", 1);
        hashMap.put("time", System.currentTimeMillis());
        Request build =
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("workout_to_3d/" + j + "/", hashMap)).build();
        Log.d(TAG, "requestWorkoutTo3D:" + build);
        return client.newCall(build);
    }

    public static void requestClubDetail(Callback callback, long j) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("teamId", j);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("team_detail", hashMap)).build();
        Log.d(TAG, "requestClubDetail:" + "request : " + build);
        client.newCall(build).enqueue(callback);
    }

    public static void uploadBiciDeviceInfo(Callback callback, Device device) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("ble_addr", device.getAddress());
        hashMap.put("bike_name", device.getName());
        if (device.getAvailable() > 0) {
            hashMap.put("bike_avaiable", device.getAvailable());
        }
        if (device.getDeviceFwVersion() > 0) {
            hashMap.put("bike_version", device.getDeviceFwVersion());
        }
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "update_device")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "uploadBiciDeviceInfo:" + build);
        client.newCall(build).enqueue(callback);
    }

    // public static Call bindBiciBike(String bcid) {
    // HashMap hashMap = new HashMap();
    // hashMap.put("bcid", bcid);
    // Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "bind_bike").post(RequestBody.create(JSON,
    // buildSimpleJson(hashMap))).build();
    // Log.d(TAG, "bindBiciBike:" + build);
    // return client.newCall(build);
    // }

    // public static void unbindBiciBike(Callback callback, String code) {
    // HashMap hashMap = new HashMap();
    // hashMap.put(/*TrackerConstant.f19688i*/"code", code);
    // Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "unbind_bike").post(RequestBody.create(JSON,
    // buildSimpleJson(hashMap))).build();
    // Log.d(TAG, "unbindBiciBike:" + build);
    // client.newCall(build).enqueue(callback);
    // }

    public static Call segmentMineCount() {
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("segment_my_count/", null)).build();
        Log.d(TAG, "segmentMineCount:" + "request : " + build);
        return client.newCall(build);
    }

    public static Call requestLevelRule() {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("time", System.currentTimeMillis());
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("level_desc/", hashMap)).build();
        Log.d(TAG, "requestLevelRule:" + build);
        return client.newCall(build);
    }

    public static Call requestLevelHP() {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("time", System.currentTimeMillis());
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("level_hp/", hashMap)).build();
        Log.d(TAG, "requestLevelHP:" + build);
        return client.newCall(build);
    }

    public static Call requestLushuElevations(long j, int i) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put(SportActivity.EXTRA_LUSHU_ID, j);
        if (i > 0) {
            hashMap.put("return_num", i);
        }
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("lushu_chart_data", hashMap)).build();
        Log.d(TAG, "requestLushuElevations:" + "request : " + build);
        return client.newCall(build);
    }

    public static Call requestMedals(int i, int i2, int i3) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put(WorkoutContentProvider.QUERY_PARAM_LIMIT, i);
        hashMap.put("page", i2);
        hashMap.put("medal_class", i3);
        hashMap.put("time", System.currentTimeMillis());
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("get_medals", hashMap)).build();
        Log.d(TAG, "requestMedals:" + "request : " + build);
        return client.newCall(build);
    }

    public static Call addBikePlaceComment(int bikeplaceId, String content, String commentPic, int action,
                                           long userId) {
        HashMap hashMap = new HashMap();
        hashMap.put("action", action);
        hashMap.put("sid", String.valueOf(bikeplaceId));
        hashMap.put("content", content);
        hashMap.put("comment_level", String.valueOf(0));
        hashMap.put("comment_pics", commentPic);
        hashMap.put("informed_user_id", userId);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "service_point/")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "addBikePlaceComment:" + build);
        return client.newCall(build);
    }

    public static Call postReply(PostClubNews postClubNews) {
        return client.newCall(getBiCiRequestBuilder(REQUEST_PREFIX, "new_team_flow")
                .post(RequestBody.create(JSON, ClubPresenter.GSON.toJson(postClubNews))).build());
    }

    public static Call postAnnouncement(PostClubNews postClubNews) {
        return client.newCall(getBiCiRequestBuilder(REQUEST_PREFIX, "new_team_flow")
                .post(RequestBody.create(JSON, ClubPresenter.GSON.toJson(postClubNews))).build());
    }

    public static void createComment(Callback callback, long topicId, String content, long informedUserId,
                                     String photoUrl, LatLng latLng) {
        HashMap hashMap = new HashMap();
        hashMap.put("topic_id", topicId);
        hashMap.put("content", content);
        if (informedUserId > 0) {
            hashMap.put("informed_user_id", informedUserId);
        }
        hashMap.put("pic_url", photoUrl);
        hashMap.put("latitude", latLng.latitude);
        hashMap.put("longitude", latLng.longitude);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "new_add_comment/")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "createComment:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call createComment(long topicId, String content, long informedUserId, String photoUrl,
                                     LatLng latLng) {
        HashMap hashMap = new HashMap();
        hashMap.put("topic_id", topicId);
        hashMap.put("content", content);
        if (informedUserId > 0) {
            hashMap.put("informed_user_id", informedUserId);
        }
        hashMap.put("pic_url", photoUrl);
        hashMap.put("latitude", latLng.latitude);
        hashMap.put("longitude", latLng.longitude);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "new_add_comment/")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "createComment:" + build);
        return client.newCall(build);
    }

    public static Call createTopic(int channelId, String title, String content, String photoUrl, LatLng latLng) {
        HashMap hashMap = new HashMap();
        hashMap.put("channel_id", channelId);
        hashMap.put("title", title);
        hashMap.put("content", content);
        hashMap.put("pic_url", photoUrl);
        hashMap.put("latitude", latLng.latitude);
        hashMap.put("longitude", latLng.longitude);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "new_add_topic/")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        Log.d(TAG, "createTopic:" + build);
        return client.newCall(build);
    }

    public static Call requestRouteSlope(long j, int i) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put(SportActivity.EXTRA_LUSHU_ID, j);
        if (i > 0) {
            hashMap.put("return_num", i);
        }
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("lushu_profile_data", hashMap)).build();
        Log.d(TAG, "requestRouteSlope:" + "request : " + build);
        return client.newCall(build);
    }

    public static Call uploadWorkoutMapId(long j, int i) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("map_id", i);
        RequestBody create = RequestBody.create(JSON, buildSimpleJson(hashMap));
        return client.newCall(
                getBiCiRequestBuilder(REQUEST_PREFIX, "workout/v1/action/" + j + "/map_setting/").post(create).build());
    }

    public static Call sportFinishReward(long j) {
        return client.newCall(getBiCiRequestBuilder(REQUEST_PREFIX, "workout/finish/" + j + "/").build());
    }

    public static Call rewardReceive(String str, long j, long j2) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("t", System.currentTimeMillis());
        // JSON.toJSONString(hashMap) TODO feng
        return client.newCall(getBiCiRequestBuilder(REQUEST_PREFIX, "workout/reward/" + str + "/" + j + "/" + j2 + "/")
                .post(RequestBody.create(JSON, JSON.toString())).build());
    }

    public static Call estPower(String str) {
        return client.newCall(getBiCiRequestBuilder(REQUEST_PREFIX, Constants.WORKOUT_DIR + str + "/est_power/")
                .post(new FormBody.Builder().build()).build());
    }

    public static Call getPowerEst(long j) {
        return client.newCall(getBiCiRequestBuilder(REQUEST_PREFIX, Constants.WORKOUT_DIR + j + "/power/").build());
    }

    public static void requestTopicsPlate(Callback callback) {
        Request build = getBiCiRequestBuilder("get_channels").build();
        Log.d(TAG, "requestTopicsPlate:" + build);
        client.newCall(build).enqueue(callback);
    }

    public static Call uploadLushuUseBehavior(long j, int i) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put(SportActivity.EXTRA_LUSHU_ID, j);
        hashMap.put("action", i);
        return client.newCall(getBiCiRequestBuilder(buildUrlByParams("lushu_use", hashMap)).get().build());
    }

    public static Call requestMedalDetail(long j, int i) {
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "medal_detail/" + j + "/" + i).build();
        StringBuilder sb = new StringBuilder();
        sb.append("request : ");
        sb.append(build);
        Log.d(TAG, "requestMedalDetail:" + sb);
        return client.newCall(build);
    }

    public static void report(Callback callback, int reportType, long reportId) {
        HashMap hashMap = new HashMap();
        hashMap.put("type", reportType);
        hashMap.put("report_id", reportId);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX, "report/")
                .post(RequestBody.create(JSON, buildSimpleJson(hashMap))).build();
        client.newCall(build).enqueue(callback);
        Log.d(TAG, "report:" + build);
    }

    public static Call getWeiXinPayInfo(String str) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("order_id", str);
        return client.newCall(
                getBiCiRequestBuilder(REQUEST_PREFIX, buildUrlByParams("check_weixin_pay_result", hashMap)).build());
    }

    public static Call setPrimaryClub(long j) {
        return client.newCall(getBiCiRequestBuilder(REQUEST_PREFIX, "team/" + j + "/set_main")
                .post(RequestBody.create(MediaType.parse("JSON"), "{}")).build());
    }

    public static Call getPrimaryClub() {
        return client.newCall(getBiCiRequestBuilder(REQUEST_PREFIX, "team/main_check").build());
    }

    public static Call requestRankUsers(int leftid, int rightid, int start, int count) {
        HashMap hashMap = new HashMap();
        hashMap.put("leftid", leftid);
        hashMap.put("rightid", rightid);
        hashMap.put("start", start);
        hashMap.put("count", count);
        Request build = getBiCiRequestBuilder(REQUEST_PREFIX,
                buildUrlByParams(App.getContext().isUserSignin() ? "get_rank_users" : "get_rank_no_users", hashMap))
                .build();
        Log.d(TAG, "requestRankUsers:" + build);
        cleanCache();
        return client.newCall(build);
    }

    public static Call requestRanktype(int cityId) {
        String str;
        if (cityId > 0) {
            str = "get_rank_type?city=" + cityId;
        } else {
            str = "get_rank_type";
        }
        Request build = getBiCiRequestBuilder(str).build();
        Log.d(TAG, "requestRanktype: cityid = " + cityId + " request : " + build);
        return client.newCall(build);
    }

    public static void getHeartRateVersion(Callback callback, String name, String currentVerNum) {
        HashMap hashMap = new HashMap();
        hashMap.put("softname", name);
        hashMap.put("vername", currentVerNum);
        Request build = getMyRequestBuilder(REQUEST_PREFIX, buildUrlByParams("fota/getNewVersion/", hashMap), false)
                .get().build();
        Log.d(TAG, "getNewVersion: " + "request : " + build);
        client.newCall(build).enqueue(callback);
    }
    ////////////// end stub///////

}
